package com.ciwong.epaper.modules.reciteWords.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.reciteWords.bean.LeardWordDayListItemBean;

import java.util.ArrayList;


public class FrgLearnedInnerAdapter extends BaseLearnAdapter<LeardWordDayListItemBean> {

    public FrgLearnedInnerAdapter(Context context) {
        super(context);
    }

    @Override
    protected BaseLearnViewHolder creatViewHolder(LayoutInflater from, ViewGroup parent, int viewType) {
        View inflate = from.inflate(R.layout.item_word_single, parent, false);
        return new UnlearnViewHolder(inflate);
    }

    @Override
    protected void binderViewHolder(BaseLearnViewHolder holder, ArrayList<LeardWordDayListItemBean> mList, int position) {
        final UnlearnViewHolder mHolder = (UnlearnViewHolder) holder;
        final LeardWordDayListItemBean listBean = mList.get(position);
        mHolder.tv_word.setText(listBean.getWordName() + "");
        if (listBean.isSelect()) {
            mHolder.tv_interpretation.setText(listBean.getInterpretation());
            mHolder.tv_interpretation.setTextColor(mContext.getResources().getColor(R.color.color_7e8883));
        } else {
            mHolder.tv_interpretation.setText(mContext.getString(R.string.word_interation));
            mHolder.tv_interpretation.setTextColor(mContext.getResources().getColor(R.color.color_light_green));
        }
        mHolder.ll_word_interpretation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listBean.setSelect(!listBean.isSelect());
                if (listBean.isSelect()) {
                    mHolder.tv_interpretation.setText(listBean.getInterpretation());
                    mHolder.tv_interpretation.setTextColor(mContext.getResources().getColor(R.color.color_7e8883));
                } else {
                    mHolder.tv_interpretation.setText(mContext.getString(R.string.word_interation));
                    mHolder.tv_interpretation.setTextColor(mContext.getResources().getColor(R.color.color_light_green));
                }

            }
        });


        mHolder.iv_go_details.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
    }

    private class UnlearnViewHolder extends BaseLearnViewHolder {

        public LinearLayout ll_word_interpretation;
        public TextView tv_word, tv_interpretation;
        public ImageView iv_go_details;

        public UnlearnViewHolder(View itemView) {
            super(itemView);
        }

        protected void initView(View itemView) {
            ll_word_interpretation = itemView.findViewById(R.id.ll_word_interpretation);
            tv_word = itemView.findViewById(R.id.tv_word);
            tv_interpretation = itemView.findViewById(R.id.tv_interpretation);
            iv_go_details = itemView.findViewById(R.id.iv_go_details);

        }
    }
}
